﻿namespace Leetcode.N0354.V1;

public class Solution
{
    // 超时
    public int MaxEnvelopes(int[][] envelopes)
    {
        envelopes = envelopes.OrderBy(_ => (long)_[0] * 100000 + _[1]).ToArray();
        var max = new int[envelopes.Length];
        for (int i = 0; i < envelopes.Length; i++)
        {
            for (int j = 0; j < i; j++)
            {
                if (envelopes[i][0] > envelopes[j][0] && envelopes[i][1] > envelopes[j][1])
                {
                    max[i] = Math.Max(max[j] + 1, max[i]);
                }
            }
        }
        return max.Max(_ => _) + 1;
    }
}
